Crop Production In The Netherlands
Graphs of crop production in the Netherlands with FAO data
Prepare Data
# devtools::install_github("derekmichaelwright/agData")
library(agData)
library(ggforce)
library(gganimate)PDF - All Netherland Crops
# Prep data
myColors <- c("darkgreen", "darkred", "darkgoldenrod2")
xx <- agData_FAO_Crops %>%
filter(Area == "Netherlands") %>%
mutate(Value = ifelse(Measurement %in% c("Area Harvested", "Production"),
Value / 1000000, Value / 1000),
Unit = plyr::mapvalues(Unit, c("hectares", "tonnes", "kg/ha"),
c("Million Hectares", "Million Tonnes", "Tonnes/ Hectare")))
myCrops <- unique(xx$Item)
# Plot
pdf("figures_crops_netherlands_fao.pdf", width = 12, height = 4)
for(i in myCrops) {
xi <- xx %>% filter(Item == i)
print(ggplot(xi, aes(x = Year, y = Value, color = Measurement)) +
geom_line(size = 1.5, alpha = 0.7) +
facet_wrap(. ~ Measurement + Unit, scales = "free_y", ncol = 3) +
scale_color_manual(values = myColors) +
scale_x_continuous(breaks = seq(1960, 2020, by = 5) ) +
theme_agData(legend.position = "none",
axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(title = i, y = NULL, x = NULL, caption = myCaption) )
}
dev.off()All Netherland Crops
# Prep data
xx <- agData_FAO_Crops %>%
filter(Area == "Netherlands", Measurement == "Production")
# Plot
ggcropplot <- function(x) {
ggplot(xx, aes(x = Year, y = Value / 100000)) +
geom_line(size = 1, color = "darkgreen", alpha = 0.7) +
scale_x_continuous(limits = c(1960, 2020),
breaks = seq(1960, 2020, 20),
minor_breaks = seq(1960, 2020, 10)) +
theme_agData() +
theme(legend.position = "none") +
labs(caption = myCaption, y = "Tonnes (x 100,000)", x = NULL)
}# Plot
mp1 <- ggcropplot(xx) +
facet_wrap_paginate(Item ~ ., scales = "free_y", labeller = label_wrap_gen(width = 45),
ncol = 5, nrow = 5, page = 1) +
labs(title = "Crop Production - Netherlands (1/2)")
mp2 <- ggcropplot(xx) +
facet_wrap_paginate(Item ~ ., scales = "free_y", labeller = label_wrap_gen(width = 45),
ncol = 5, nrow = 5, page = 2) +
labs(title = "Crop Production - Netherlands (2/2)")
ggsave("crops_netherlands_01.png", mp1, width = 15, height = 8)
ggsave("crops_netherlands_02.png", mp2, width = 15, height = 8)Netherlands vs Europe
# Prep data
myCrops <- c("Potatoes", "Sugar beet", "Wheat", "Tomatoes", "Carrots and turnips",
"Onions and shallots, dry (excluding dehydrated)")
xx <- agData_FAO_Crops %>%
filter(Area %in% c("Netherlands", "Europe"), Item %in% myCrops,
Measurement == "Yield") %>%
mutate(Area = factor(Area, levels = c("Netherlands", "Europe")),
Item = plyr::mapvalues(Item, myCrops[6], "Onions"))
# Plot
mp <- ggplot(xx, aes(x = Year, y = Value / 1000, color = Area)) +
geom_line(alpha = 0.7, size = 1.5) +
facet_wrap(Item ~ ., scales = "free_y", ncol = 3) +
scale_color_manual(name = NULL, values = c("darkgreen", "darkblue")) +
scale_x_continuous(breaks = seq(1960, 2020, 10), minor_breaks = NULL) +
theme_agData(legend.position = "bottom") +
labs(title = "Yields in Netherlands and Europe",
x = NULL, y = "Tonnes / Hectare", caption = myCaption)
ggsave("crops_netherlands_03.png", mp, width = 10, height = 6)